package com.example.administrator.x2picturetransliteration;

import android.app.Application;
import com.example.administrator.x2picturetransliteration.Dao.GreenDaoManager;
import com.example.administrator.x2picturetransliteration.Util.SpUtils;
import com.orhanobut.logger.AndroidLogAdapter;
import com.orhanobut.logger.Logger;
import com.squareup.leakcanary.LeakCanary;
import com.umeng.commonsdk.UMConfigure;
import com.umeng.socialize.PlatformConfig;


/**
 * 2018/10/9.
 */

public class ExampleApplication extends Application {

    protected static volatile ExampleApplication application;

    public static ExampleApplication getInstance() {
        return application;
    }


    //各个平台的配置
    {
        //微信
        PlatformConfig.setWeixin("wx46c53a8a4dec99ab", "5ddc955751a674d480b722d13089b390");
        //QQ
        PlatformConfig.setQQZone("101887855", "f4a569c2533a0267cb7d73cb4efe9f01");
    }

    @Override
    public void onCreate() {
        super.onCreate();


        //初始化友盟
//        UMConfigure.init(this, "5f51d8ef7823567fd863db15", null, UMConfigure.DEVICE_TYPE_PHONE, "");
//        UMConfigure.setLogEnabled(true);

        UMConfigure.preInit(this, "5f51d8ef7823567fd863db15", null);
        if(SpUtils.getInstance().getAgree(this)){
            UMConfigure.init(this, UMConfigure.DEVICE_TYPE_PHONE, "");
        }
        UMConfigure.setLogEnabled(true);


        if (!LeakCanary.isInAnalyzerProcess(this)) {

            LeakCanary.install(this); //启用Leaks(---内存泄漏检测)
        }

        GreenDaoManager.init(this); //启用GreenDaoManager工具类greendao(---数据库)

        Logger.addLogAdapter(new AndroidLogAdapter());  //启用logger(---日志)

        RxBus.getInstance().start(); //开启RxBus

    }

    @Override
    public void onTerminate() {
        super.onTerminate();

        RxBus.getInstance().end(); //关闭RxBus
    }

}